import { defineAsyncComponent } from 'vue'

// 这里你的公共组件位于 src/components 目录
const components = {
    JrAutocomplete: defineAsyncComponent(() =>
        import('./MetaForm/JrAutocomplete.vue')
    ),
    JrCascader: defineAsyncComponent(() => import('./MetaForm/JrCascader.vue')),
    JrCheckbox: defineAsyncComponent(() => import('./MetaForm/JrCheckbox.vue')),
    JrDatePicker: defineAsyncComponent(() =>
        import('./MetaForm/JrDatePicker.vue')
    ),
    JrInput: defineAsyncComponent(() => import('./MetaForm/JrInput.vue')),
    JrInputNumber: defineAsyncComponent(() =>
        import('./MetaForm/JrInputNumber.vue')
    ),
    JrPreview: defineAsyncComponent(() => import('./MetaForm/JrPreview.vue')),
    JrRadio: defineAsyncComponent(() => import('./MetaForm/JrRadio.vue')),
    JrSelect: defineAsyncComponent(() => import('./MetaForm/JrSelect.vue')),
    JrSelectRemote: defineAsyncComponent(() =>
        import('./MetaForm/JrSelectRemote.vue')
    ),
    JrSelectRemoteUrl: defineAsyncComponent(() =>
        import('./MetaForm/JrSelectRemoteUrl.vue')
    ),
    JrSwitch: defineAsyncComponent(() => import('./MetaForm/JrSwitch.vue')),
    JrPlainText: defineAsyncComponent(() =>
        import('./MetaForm/JrPlainText.vue')
    ),
    JrTimePicker: defineAsyncComponent(() =>
        import('./MetaForm/JrTimePicker.vue')
    ),
    JrUpload: defineAsyncComponent(() => import('./MetaForm/JrUpload.vue')),
    JrEmpty: defineAsyncComponent(() => import('./MetaTable/JrEmpty.vue')),
    JrLoading: defineAsyncComponent(() => import('./MetaTable/JrLoading.vue')),
    MetaRender: defineAsyncComponent(() =>
        import('./MetaTable/MetaRender.vue')
    ),

    MetaCard: defineAsyncComponent(() => import('./MetaCard/index.vue')),
    MetaTitle: defineAsyncComponent(() => import('./MetaTitle/index.vue')),
    MetaCenter: defineAsyncComponent(() => import('./MetaCenter/index.vue')),
    MetaForm: defineAsyncComponent(() => import('./MetaForm/index.vue')),
    MetaIcon: defineAsyncComponent(() => import('./MetaIcon/index.vue')),
    MetaTable: defineAsyncComponent(() => import('./MetaTable/index.vue')),
    MetaTop: defineAsyncComponent(() => import('./MetaTop/index.vue')),
    MetaDialog: defineAsyncComponent(() => import('./MetaDialog/index.vue'))
}

export default {
    install(app) {
        for (const [name, component] of Object.entries(components)) {
            app.component(name, component)
        }
    }
}
